package com.hhy.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @Description 生成一个随机的号码
 * @Author hhy
 * @Date 2020/10/29 9:38
 */
public class NumBerPool {
    private static Integer number = 5;

    //移动手机号码开头一共有16个
    static int numbersHead[] = {134,135,136,137,138,139,147,150,151,152,157,158,159,182,187,188};
    public static Long createNewPhoneNumer(){
        int index = (int) (Math.random() * numbersHead.length);
        long num = numbersHead[index]*100000000L;
        return  (long)(Math.random()*90000000+10000000) + num;
    }

    //返回一个号码池，默认为5
    public static List<Long> numberList(){
        ArrayList<Long> phoneNumbers = new ArrayList<>();
        for (int i = 0; i < number; i++) {
            phoneNumbers.add(createNewPhoneNumer());
        }
        return phoneNumbers;
    }
    //重载方法，是的这个方法可以自定义的选择数量
    public static List<Long> numberList(int number){
        ArrayList<Long> phoneNumbers = new ArrayList<>();
        for (int i = 0; i < number; i++) {
            phoneNumbers.add(createNewPhoneNumer());
        }
        return phoneNumbers;
    }
}
